#pragma once
//============================================================================
// Copyright (C) 2009-2013 Brett R. Jones 
// All Rights Reserved
//
// You may redistribute and/or modify for non commercial and commercial uses 
// provided this copyright notice remains in place and is not modified
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// brettjones1900@gmail.com
// http://www.p2panarchy.com
//============================================================================
#include <VxNetLib/VxSktBase.h> 

// type of request being made
enum EHttpReqType 
{
	eHttpReqUnknown = 0,
	eHttpReqGet		= 1,
	eHttpReqPost	= 2,
};

class VxWebServer;

enum EWbMyFiles
{
	eWbMyFilesNone			= 0,
	eWbMyFilesImages		= 1,
	eWbMyFilesMusic			= 2,
	eWbMyFilesVideos		= 3,
	eWbMyFilesOther			= 4,
	eMaxNormalWbMyFiles		= 5,

	eWbMyFilesError			= 6,
	eWbMyFilesPersonal		= 7,
	eWbMyFilesArchive		= 8,
	eWbMyFilesDocuments		= 9,
	eWbMyFilesIsos			= 10,
	eWbMyFilesRes1			= 11,
	eWbMyFilesRes2			= 12,

	eMaxAllWbMyFiles		// must be last
};


class WbQueEntry
{
public:
	//=== constructor ===//
	WbQueEntry()
		: m_eFileType( eWbMyFilesNone )
		, m_eHttpReqType( eHttpReqUnknown )
	{
		// empty
	}
	//=== vars ===//
	std::string			m_strFileName;
	std::string			m_strPwd;
	EWbMyFiles			m_eFileType;
	EHttpReqType		m_eHttpReqType;
};

class VxWebSkt : public VxSktBase
{
public:
	//=== constructor ===//
	VxWebSkt();
	//=== destructor ===//
	~VxWebSkt();

	//=== overrides ===//


	//=== methods ===//
	//! que up a file to be sent
	RCODE	QueWebsiteFile( const char *	pFileName,		// file name or password
							EWbMyFiles		eFileType,		// file type if alias for shared file
							EHttpReqType	eHttpReqType,	// http request type
							const char *	pPwd );			// password

	//! transmit file to browser
	RCODE	DoSendFile( const char * pFileName );


	//=== vars ===//
	VxWebServer *	m_poWebMgr;

	FILE *			m_poFile;
	U64				m_u64FileLen;			// total file len
	U64				m_u64LenSent;			// how much of file has been sent
	std::string		m_strWebFileName;
	std::string		m_strRealFileName;

	std::vector<WbQueEntry> m_aoQuedFiles;	// files and prompts qued to be sent
};
